/**
 * MarioPawn
 * @extends UTPawn
 * @version 2010.11.30
 */

class MarioPawn extends UTPawn;

/* Attribute fields */
var int coins;
var int score;
var int timeLeft;
var int lives;

var bool bIsBig;

/* Movement fields */
var float topRunningSpeed, topWalkingSpeed;
var float walkingAccelRate, runningAccelRate;
var int   reduceSpeedFrameCount;
var float timerInc;
var bool inair;
//What does this do?
var float slope;

/**
 * PostBeginPlay
 * @version 2010.12.3
 */
simulated function PostBeginPlay()
{
	Super.PostBeginPlay();
	slope = -(topRunningSpeed - topWalkingSpeed);
	ShrinkHeight();
}

event Landed (Object.Vector HitNormal, Actor FloorActor) {
		super.Landed(HitNormal, FloorActor);
		inair=false;
	}

simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
   // Calculate first person camera position and rotation
   GetActorEyesViewPoint( out_CamLoc, out_CamRot );

   return true;
}   

/**
 * Timer
 * @version 2010.12.3
 */
function Timer()
{
	GroundSpeed = slope * (timerInc * reduceSpeedFrameCount) + topRunningSpeed;
	AirSpeed    = GroundSpeed;

	if(GroundSpeed < topWalkingSpeed)
	{
		//destroy timer and set count to 1
		GroundSpeed = topWalkingSpeed;
		AirSpeed    = topWalkingSpeed;

		//set for next time
		reduceSpeedFrameCount = 1; 
		ClearTimer();
	}
	else 
		reduceSpeedFrameCount++;
}

function bool isinair()
{
	return inair;
}

/**
 * Run
 * @version 2010.12.3
 */
exec function Run()
{
	ClearTimer();
	GroundSpeed = topRunningSpeed;
	AirSpeed    = topRunningSpeed;
	AccelRate   = runningAccelRate;
}

exec function pressedJump()
{
	inair = true;
}

/**
 * StopRunning
 * @version 2010.12.3
 */
exec function stopRunning()
{
	SetTimer(timerInc, true);
}

/**
 * GrowHeight
 * @version 2010.12.05
 */
function GrowHeight()
{
	if(!bIsBig)
	{
		CylinderComponent.SetCylinderSize(CylinderComponent.CollisionRadius, CylinderComponent.CollisionHeight + 40.0);
		bIsBig = true;
	}
}

/**
 * ShrinkHeight
 * @version 2010.12.05
 */
function ShrinkHeight()
{
	if(bIsBig)
	{
		CylinderComponent.SetCylinderSize(CylinderComponent.CollisionRadius, CylinderComponent.CollisionHeight - 40.0);
		bIsBig = false;
	}
}

DefaultProperties
{
	//bBlockActors = true;

	Health      = 50;
	HealthMax   = 150;
	timeLeft = 1000;
	inair = false;

	//CylinderComponent.SetCylinderSize(CylinderComponent.CollisionRadius, CylinderComponent.CollisionHeight - 40.0);
	bCollideActors = true;

	bIsBig = false;

	topRunningSpeed = 550.0
    topWalkingSpeed = 250.0

	BaseEyeHeight = 32.0;

    GroundSpeed = 250.0
    AirSpeed    = 250.0

	runningAccelRate = 350.0
    walkingAccelRate = 200.0
    AccelRate        = 350.0

    reduceSpeedFrameCount = 1
    timerInc = 0.01
  
    JumpZ       = 800.0
	FullHeight  = 40.0

	bCanPickupInventory = false;

	CollisionType=COLLIDE_BlockAll
	Begin Object Name=CollisionCylinder
		CollisionRadius=+0023.000000
		CollisionHeight=+0048.000000
	End Object
	CylinderComponent=CollisionCylinder

	
}

	function increaseScoreBy(int i){

		score = score + i;
	}

	function decreaseTime(){
		timeLeft = timeLeft - 1;
	}

	function increaseCoinsBy(int i){

		
		coins = coins + i;

		if(coins > 99){
			coins = 0;
			lives = lives + 1;
		}
	}